package com.aizuda.boot.modules.business.contract.controller;


import com.aizuda.boot.modules.business.contract.dto.SingleResponse;
import com.aizuda.boot.modules.business.contract.entity.dto.WorkflowTypeAddRequest;
import com.aizuda.boot.modules.business.contract.entity.dto.WorkflowTypeSortRequest;
import com.aizuda.boot.modules.business.contract.entity.dto.WorkflowTypeUpdateRequest;
import com.aizuda.boot.modules.business.contract.entity.vo.WorkflowTypeResponse;
import com.aizuda.boot.modules.business.contract.service.WorkflowTypeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author sangyirong
 * @ClassName WorkflowTypeController
 * @Version 1.0
 * @Date 2025/6/10 19:14
 */
@RestController
@RequestMapping("/workflowType")
@Tag(name = "流程类型管理")
public class WorkflowTypeController {

    @Resource
    private WorkflowTypeService workflowTypeService;

    @GetMapping("/list")
    @Operation(summary = "获取流程类型列表")
    public SingleResponse<List<WorkflowTypeResponse>> queryWorkflowTypeList() {
        return workflowTypeService.queryWorkflowTypeList();
    }

    @PostMapping("/add")
    @Operation(summary = "新增流程类型")
    public SingleResponse<Void> createWorkflowType(@Validated @RequestBody WorkflowTypeAddRequest request) {
        return workflowTypeService.createWorkflowType(request);
    }

    @GetMapping("/get/{id}")
    @Operation(summary = "获取流程类型详情")
    public SingleResponse<WorkflowTypeResponse> getWorkflowTypeById(@PathVariable Integer id) {
        return workflowTypeService.getWorkflowTypeById(id);
    }

    @PutMapping("/update")
    @Operation(summary = "更新流程类型")
    public SingleResponse<Void> updateWorkflowType(@Validated @RequestBody WorkflowTypeUpdateRequest request) {
        return workflowTypeService.updateWorkflowType(request);
    }

    @DeleteMapping("/delete/{id}")
    @Operation(summary = "删除流程类型")
    public SingleResponse<Void> removeWorkflowType(@PathVariable Integer id) {
        return workflowTypeService.removeWorkflowType(id);
    }

    @PutMapping("/sort")
    @Operation(summary = "流程类型排序")
    public SingleResponse<Void> sortWorkflowType(@Validated @RequestBody WorkflowTypeSortRequest request) {
        return workflowTypeService.sortWorkflowType(request);
    }
}
